class Solution:
    def largestSubmatrix(self, matrix: list) -> int:
        array = [[0 for _ in range(len(matrix[0]))]
                 for _ in range(len(matrix))]
        for j in range(len(matrix[0])):
            cnt = 0
            for i in range(len(matrix)):
                if matrix[i][j] == 1:
                    cnt += 1
                else:
                    cnt = 0
                array[i][j] = cnt
        ans = 0
        for i in range(len(array)):
            array[i].sort(reverse=True)
            for j in range(len(array[i])):
                area = (j + 1) * array[i][j]
                ans = max(area, ans)

        return ans
